﻿package com.eitb.rutas{
	import flash.net.*;
	import flash.external.*;

	public class Rutas {
//		public static var DOMINIO:String = "http://".concat(new LocalConnection().domain).concat("/");
		public static var DOMINIO:String = "http://www.eitb.com/";
		public static var CURRENT_URL:String = new String( ExternalInterface.call(" function(){ return document.location.href.toString();}"));
		private static  const RUTA_XML:String = "multimedia/infografias/swf/xmls/";
		private static  const MULTI:String = "multi";

		public function getRutaXml(id:String, idioma:String):URLRequest {
			var request:URLRequest = new URLRequest(Rutas.DOMINIO.concat(Rutas.RUTA_XML).concat(id).concat(new String("_")).concat(idioma).concat(".xml"));
			var variables:URLVariables = new URLVariables();
			variables.rnd = Math.ceil(Math.random() * 100000000).toString();
			request.data = variables;
			request.method = URLRequestMethod.POST;
			request.requestHeaders.push(new URLRequestHeader("pragma", "no-cache"));
			return request;
		}
		public function getRutaImagen(url:String):URLRequest {
			var request:URLRequest = new URLRequest(Rutas.DOMINIO.concat(this.normalizeUrlPath(url)));
			request.method = URLRequestMethod.POST;
			request.requestHeaders.push(new URLRequestHeader("pragma", "no-cache"));
			return request;
		}
		public function getRutaVideo(url:String):URLRequest {
			var request:URLRequest = new URLRequest(Rutas.DOMINIO.concat(this.normalizeUrlPath(url)));
			request.method = URLRequestMethod.POST;
			request.requestHeaders.push(new URLRequestHeader("pragma", "no-cache"));
			return request;
		}
		private function normalizeUrlPath(cmsPath:String):String {
			return Rutas.MULTI.concat(cmsPath.substring(1));
		}
	}
}